<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/jsp/admin/include/headBase.jsp"/>
</head>
<body style="padding-left: 40px">
<br>
<br>
<br>
<div>
    <form id="form_businessInfo" class="form-horizontal row">
        <div class="col-sm-10" id="div-error"></div>
        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">经办人：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="managerUserId" value="4325" placeholder="4325">
            </div>
        </div>
        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">观察员：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="observerUserId" value="3940" placeholder="3940">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">单位代码：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="companyCode">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">单位名称：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="companyName">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">产品名称：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="productName">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">业务号：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="businessCode">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">事项：</label>
            <div class="col-sm-8">
                <select class="form-control" id="itemNum" name="itemNum"
                        data-s35='{3501:"首次",3502:"复查",3503:"扩项",3504:"名称变更",3505:"补领",3506:"标准变更",3507:"授权签字人变更",3508:"场所变更",3509:"相关人员备案"}'
                        data-s43='{4301:"发证",4302:"延续",4303:"许可范围跟变",4304:"名称更变",4305:"补领",4306:"集团公司",4307:"其他"}'>
                    <option value="">&nbsp;</option>
                    <option value="43">工许</option>
                    <option value="35">检验检测</option>
                </select>
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">业务类型：</label>
            <div class="col-sm-8">
                <select class="form-control" id="businessType" name="businessType">
                    <option value=''>&nbsp;</option>
                </select>

            </div>
        </div>





        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">申请日期：</label>
            <div class="col-sm-8">
                <div class="input-group date form_date timeInput">
                                                <span class="input-group-addon"><span
                                                        class="glyphicon glyphicon-calendar"></span></span>
                    <input class="form-control" type="text"
                           name="applicationTime" readonly>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-5">
            <label class="col-sm-4 control-label">受理日期：</label>
            <div class="col-sm-8">
                <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                    <input class="form-control" type="text" name="acceptTime" readonly>
                </div>
            </div>
        </div>


        <div class="form-group col-sm-10">
            <label class="control-label col-sm-2">专业：</label>
            <div class="col-sm-10">
                <input type="text" readonly id="citySel1" class="form-control" >
                <div id='menuContent1' style="display: none; position: relative; height: 0px;z-index: 100">
                    <div style="background-color: #f5f5f5;border: 1px solid #ccc">
                        <div style="overflow-y:auto; overflow-x:auto; max-height: 200px; ">
                            <ul id="treeDemo1" class="ztree"></ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group col-sm-5">
            <label class="control-label col-sm-4">核查地址：</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="address">
            </div>
        </div>

        <div class="form-group col-sm-5">
            <div class="col-sm-8 col-sm-offset-4">
                <button type="submit" class="btn btn-default btn-success">
                    <span class="glyphicon glyphicon-plus-sign"></span>&nbsp;添&nbsp;加&nbsp;
                </button>
            </div>
        </div>
    </form>
</div>
<jsp:include page="/WEB-INF/jsp/admin/include/footerBase.jsp"/>
<script>
    $(function () {
        <%--bootstrapValidator--%>
        var $form = $("#form_businessInfo");
        $form.bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                manager: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        },
                        stringLength: {
                            max: 40,
                            message: '不能超过40个字符！'
                        }
                    }
                },
                observer: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        },
                        stringLength: {
                            max: 40,
                            message: '不能超过40个字符！'
                        }
                    }
                },
                companyCode: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        },
                        stringLength: {
                            max: 40,
                            message: '不能超过40个字符！'
                        }
                    }
                },
                companyName: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        }
                    }
                },
                productName: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        }
                    }
                },
                businessCode: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        }
                    }
                },
                businessType: {
                    validators: {
                        notEmpty: {
                            message: '不能为空！'
                        }
                    }
                },
                applicationTime: {
                    validators: {
                        notEmpty: {
                            message: '不能为空!'
                        }
                    }
                },
                acceptTime: {
                    validators: {
                        notEmpty: {
                            message: '不能为空!'
                        }
                    }
                },
                itemNum: {
                    validators: {
                        notEmpty: {
                            message: '不能为空!'
                        }
                    }
                },
                address: {
                    validators: {
                        notEmpty: {
                            message: '不能为空!'
                        }
                    }
                },
                majors: {
                    validators: {
                        notEmpty: {
                            message: '不能为空!'
                        }
                    }
                }
            }
        }).on('success.form.bv', function (e) {
            e.preventDefault();

            var treeObj = $.fn.zTree.getZTreeObj("treeDemo1");
            var nodes = treeObj.getCheckedNodes(true);

            var ids = new Array();
            for (var i = 0; i < nodes.length; i++) {
                if (!nodes[i].isParent)
                    ids.push(nodes[i].data);
            }
            if (ids.length == 0) {
                alert("专业不能为空");
                return;
            }
            var data = $(e.target).serializeObject();
            data['majorNumList'] = ids.toString();
            var url, operateType;

            $.sysPlugin.superAjax({
                data: data,
                url: "${base}/httpPage/addBusiness",
                operateType: 'insert',
                showSuccessAlert: true,
                showWarnAlert: false,
                successCall: function (data) {
                },
                errorCall: function (data) {
                    $.sysPlugin.errorCallBack(data, {
                        errorAddress: $("#div-error"),
                        form: $form
                    })
                }
            });
        });
        $.sysPlugin.initSimpleSelect2();
        $.sysPlugin.initDateTimeInput();
    });
</script>
<script>
    $("#itemNum").change(function () {
        var v = $(this).data("s" + $(this).val()), str = "<option value=''>&nbsp;</option>";
        if (v != undefined) {
            var obj = eval("(" + v + ")");
            $.each(obj, function (k, v) {
                str = str + '<option value=' + k + '>' + v + '</option>'
            });
        }
        $("#businessType").html(str);
        $.sysPlugin.initSimpleSelect2($("#businessType"));
    })


</script>


<script>


    $(function () {
        var selectTree = new ApmZTreeUtil(
                $("#citySel1"),
                $("#menuContent1"),
                $("#treeDemo1")
        ), setting = {
            check: {
                enable: true,
                checkboxType: {"Y": "", "N": ""}
            },
            view: {
                dblClickExpand: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            async: {
                enable: true,
                url: "${base}/httpPage/getProfessionTree",
//                autoParam: ["id"],
//                otherParam:{"id":$("#id").val()},
//                dataFilter: filter
            },
            callback: {
                beforeClick: selectTree.beforeClick,
                onCheck: selectTree.onCheck
            }
        };
        $("#citySel1").on('click', function () {
            selectTree.showMenu();
        });
        $.fn.zTree.init($("#treeDemo1"), setting);
    });


</script>

</body>
</html>